package com.app.common.download;

public class DownloadStatus {
    public enum Status{
        REQ(0),
        REQ_ERROR(-1),
        START(1),
        PROGRESS(2),
        FAILED(-2),
        CANCELED(-3),
        COMPLETE(3);

        private int flag;
        Status(int i){
            this.flag = i;
        }
        public boolean failed(){
            return this.flag < 0;
        }
    }

    public DownloadStatus(Download downloader){
        this.status = Status.REQ;
        this.downloader = downloader;
    }

    public DownloadStatus(Download downloader, Status status){
        this.status = status;
        this.downloader = downloader;
    }

    private Status status = Status.REQ;
    private final Download downloader;

    private float progress = 0.0f;

    public Download getDownloader(){
        return downloader;
    }

    public Status getStatus(){
        return this.status;
    }

    public float getProgress(){
        return progress;
    }
    public void setProgress(float progress){
        this.progress = progress;
    }
}
